import { Point } from '../utils/Point'
import { DOCMAP, IP, PORT } from '../constants'
const source = new ol.source.Vector({
  title: '添加收藏',
  wrapX: false,
})
const collayer = new ol.layer.Vector({
  title: '',
  source,
})
var docLayer = new Zondy.Map.Doc('', DOCMAP, {
  IP,
  PORT,
})
export const addPnt = (e, map) => {
  if (e == 0) {
    map.interactions.pop()
    map.on('click', window.handleClick)
    // console.log(window.handleClick)
    map.addLayer(collayer)
    map.addLayer(docLayer)
    // console.log(map.listeners_.click)
  }
}
// console.log(window)
window.handleClick = (e) => {
  let position = e.coordinate
  let attr = [{ key: 'name', value: '收藏点', type: 'string' }]
  let service = { docName: DOCMAP, layerId: 5 }
  Point.add({
    position,
    attr,
    service,
    docLayer,
  })
}
